<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
 <meta>
  <!-- Stylesheets -->
  <link href="../web.css" type="text/css" rel="stylesheet"></link>
  <link href="../pygmentize.css" type="text/css" rel="stylesheet"></link>
  <title>VLFeat - Documentation - C API</title>
  <link rel="stylesheet" type="text/css" href="../doxygen.css"></style>

  <!-- Scripts-->
  
 </meta>

 <!-- Body Start -->
 <body>
  <div id="header">
   <!-- Google CSE Search Box Begins -->
   <form action="http://www.vlfeat.org/search.html" method="get" id="cse-search-box" enctype="application/x-www-form-urlencoded">
    <div>
     <input type="hidden" name="cx" value="003215582122030917471:oq23albfeam"></input>
     <input type="hidden" name="cof" value="FORID:11"></input>
     <input type="hidden" name="ie" value="UTF-8"></input>
     <input type="text" name="q" size="31"></input>
     <input type="submit" name="sa" value="Search"></input>
    </div>
   </form>
   <script src="http://www.google.com/coop/cse/brand?form=cse-search-box&amp;lang=en" xml:space="preserve" type="text/javascript"></script>
   <!-- Google CSE Search Box Ends -->
   <h1><a shape="rect" href="../index.html" class="plain"><span id="vlfeat">VLFeat</span><span id="dotorg">.org</span></a></h1>
  </div>
  <div id="headbanner">
   Documentation - C API
  </div>
  <div id="pagebody">
   <div id="sidebar"> <!-- Navigation Start -->
    <ul>
<li><a href="../index.html">Home</a>
</li>
<li><a href="../download.html">Download</a>
</li>
<li><a href="../doc.html">Documentation</a>
<ul>
<li><a href="../mdoc/mdoc.html">Matlab API</a>
</li>
<li><a href="index.html" class='active' >C API</a>
</li>
<li><a href="../man/man.html">Man pages</a>
</li>
</ul></li>
<li><a href="../overview/tut.html">Tutorials</a>
</li>
<li><a href="../applications/apps.html">Applications</a>
</li>
</ul>

   </div> <!-- sidebar -->
   <div id="content">
    
    <link rel="stylesheet" type="text/css" href="../doxygen.css"></style>
    <div class="doxygen">
<div>
<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#enum-members">Enumerations</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">lbp.h File Reference</div>  </div>
</div>
<div class="contents">

<p>Local Binary Patterns.  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &quot;<a class="el" href="generic_8h.html">generic.h</a>&quot;</code><br/>
</div><table class="memberdecls">
<tr><td colspan="2"><h2><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structVlLbp.html">VlLbp</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Local Binary Pattern extractor.  <a href="structVlLbp.html#details">More...</a><br/></td></tr>
<tr><td colspan="2"><h2><a name="enum-members"></a>
Enumerations</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="lbp_8h.html#add3c75c3439f492a9c4b445d80af3d48">VlLbpMappingType</a> { <a class="el" href="lbp_8h.html#add3c75c3439f492a9c4b445d80af3d48a56d4fb4c61f28ddf9fb2569935a5a9a4">VlLbpUniform</a>
 }</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Type of quantization for LBP features.  <a href="lbp_8h.html#add3c75c3439f492a9c4b445d80af3d48">More...</a><br/></td></tr>
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="structVlLbp.html">VlLbp</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="lbp_8h.html#a3e6b2fc3465c379f3acc45c9fe5b179c">vl_lbp_new</a> (<a class="el" href="lbp_8h.html#add3c75c3439f492a9c4b445d80af3d48">VlLbpMappingType</a> type, <a class="el" href="host_8h.html#ad32e7f8ec7333ff33998cf671a3b1412">vl_bool</a> transposed)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Create a new LBP object.  <a href="#a3e6b2fc3465c379f3acc45c9fe5b179c"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="lbp_8h.html#af4061c7ff063118d14893cafe5b55ed8">vl_lbp_delete</a> (<a class="el" href="structVlLbp.html">VlLbp</a> *self)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Delete <a class="el" href="structVlLbp.html" title="Local Binary Pattern extractor.">VlLbp</a> object.  <a href="#af4061c7ff063118d14893cafe5b55ed8"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="lbp_8h.html#a605c416d7ab3906609cbb62404a20253">vl_lbp_process</a> (<a class="el" href="structVlLbp.html">VlLbp</a> *self, float *features, float *image, <a class="el" href="host_8h.html#a0ee26101458c663510d620e3ee7e2555">vl_size</a> width, <a class="el" href="host_8h.html#a0ee26101458c663510d620e3ee7e2555">vl_size</a> height, <a class="el" href="host_8h.html#a0ee26101458c663510d620e3ee7e2555">vl_size</a> cellSize)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Extract LBP features.  <a href="#a605c416d7ab3906609cbb62404a20253"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="host_8h.html#a0ee26101458c663510d620e3ee7e2555">vl_size</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="lbp_8h.html#a9fdc1d38de7ce1494cdd911bfd8957a7">vl_lbp_get_dimension</a> (<a class="el" href="structVlLbp.html">VlLbp</a> *self)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the dimension of the LBP histograms.  <a href="#a9fdc1d38de7ce1494cdd911bfd8957a7"></a><br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p><a class="el" href="structVlLbp.html" title="Local Binary Pattern extractor.">VlLbp</a> implements the local binary pattern features.</p>
<p>An LBP feature [1] is a l2-normalized local histogram of quantized local binary patterns (LBP).</p>
<h2><a class="anchor" id="lbp"></a>
Local Binary Patterns</h2>
<p>A LBP is a string of bit obtained by binarizing a local neighbourhood of pixels with respect to the brightness of the central pixel. <a class="el" href="structVlLbp.html" title="Local Binary Pattern extractor.">VlLbp</a> implements only the case of 3x3 pixel neighbourhoods (this setting perform best in applications). Thus the LBP at location <img class="formulaInl" alt="$ (x,y) $" src="form_184.png"/> is a string of eight bits. Each bit is equal to one if the corresponding pixel is brighter than the central one. Pixels are scanned starting from the one to the right in anti-clockwise sense. For example the first bit is one if, and only if, <img class="formulaInl" alt="$ I(x+1,y) > I(x,y), and the second bit if, and only if, $" src="form_185.png"/> I(x+1,y-1) &gt; I(x,y).</p>
<h3><a class="anchor" id="lbp-quantization"></a>
Quantized LBP</h3>
<p>For a 3x3 neighborhood, an LBP is a string of eight bits and so there are 256 possible LBPs. These are usually too many for a reliable statistics (histogram) to be computed. Therefore the 256 patterns are further quantized into a smaller number of patterns according to one of the following rules:</p>
<ul>
<li><b>Uniform</b> (<a class="el" href="lbp_8h.html#add3c75c3439f492a9c4b445d80af3d48a56d4fb4c61f28ddf9fb2569935a5a9a4">VlLbpUniform</a>) There is one quantized pattern for each LBP that has exactly a transitions from 0 to 1 and one from 1 to 0 when scanned in anti-clockwise order, plus one quantized pattern comprising the two uniform LBPs, and one quantized pattern comprising all the other LBPs. This yields a total of 58 quantized patterns.</li>
</ul>
<p>The number of quantized LBPs, which depends on the quantization type, can be obtained by <a class="el" href="lbp_8h.html#a9fdc1d38de7ce1494cdd911bfd8957a7" title="Get the dimension of the LBP histograms.">vl_lbp_get_dimension</a>.</p>
<h3><a class="anchor" id="lbp-histograms"></a>
Histograms of LBPs</h3>
<p>The quantized LBP patterns are further grouped into local histograms. The image is divided into a number of cells of a prescribed size (<code>cellSize</code>). Then the quantized LBPs are aggregated into histogram by using bilinear interpolation along the two spatial dimensions (similar to HOG and SIFT).</p>
<h3><a class="anchor" id="lbp-usage"></a>
Usage</h3>
<p>First, one creates a <a class="el" href="structVlLbp.html" title="Local Binary Pattern extractor.">VlLbp</a> object instance by specifying the type of quantization (this initializes some internal tables to speedup the computation). Then, one obtains all the quantized LBPs histograms by calling <a class="el" href="lbp_8h.html#a605c416d7ab3906609cbb62404a20253" title="Extract LBP features.">vl_lbp_process</a>. This function expects as input a buffer large enough to contain the computed features. If the image has size <code>width</code> x <code>height</code>, there are exactly <code>floor</code>(width/cellSize) x <code>floor</code>(height/cellSize) cells, each of which has a histogram of LBPs of size <code>dimension</code> (as returned by <a class="el" href="lbp_8h.html#a9fdc1d38de7ce1494cdd911bfd8957a7" title="Get the dimension of the LBP histograms.">vl_lbp_get_dimension</a>). Thus the required buffer has size <code>floor</code>(width/cellSize) x <code>floor</code>(height/cellSize) x <code>dimension</code>.</p>
<p><a class="el" href="structVlLbp.html" title="Local Binary Pattern extractor.">VlLbp</a> supports computing transposed LPBs as well. A transposed LBP is the LBP obtained by transposing the underlying image patch (regarded as a matrix). This can be useful to compute the features when the image is column major rather than row major.</p>
<h2><a class="anchor" id="lbp-references"></a>
References</h2>
<p>[1] T. Ojala, M. Pietikainen, and M. Maenpaa. "Multiresolution gray-scale and rotation invariant texture classification with local binary patterns". PAMI, 2010.</p>
<dl class="author"><dt><b>Author:</b></dt><dd>Andrea Vedaldi </dd></dl>
</div><hr/><h2>Enumeration Type Documentation</h2>
<a class="anchor" id="add3c75c3439f492a9c4b445d80af3d48"></a><!-- doxytag: member="lbp.h::VlLbpMappingType" ref="add3c75c3439f492a9c4b445d80af3d48" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="lbp_8h.html#add3c75c3439f492a9c4b445d80af3d48">VlLbpMappingType</a></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Enumerator: </b></dt><dd><table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><em><a class="anchor" id="add3c75c3439f492a9c4b445d80af3d48a56d4fb4c61f28ddf9fb2569935a5a9a4"></a><!-- doxytag: member="VlLbpUniform" ref="add3c75c3439f492a9c4b445d80af3d48a56d4fb4c61f28ddf9fb2569935a5a9a4" args="" -->VlLbpUniform</em>&nbsp;</td><td>
<p>Uniform patterns </p>
</td></tr>
</table>
</dd>
</dl>

</div>
</div>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="af4061c7ff063118d14893cafe5b55ed8"></a><!-- doxytag: member="lbp.h::vl_lbp_delete" ref="af4061c7ff063118d14893cafe5b55ed8" args="(VlLbp *self)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void vl_lbp_delete </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structVlLbp.html">VlLbp</a> *&#160;</td>
          <td class="paramname"><em>self</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>object to delete. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a9fdc1d38de7ce1494cdd911bfd8957a7"></a><!-- doxytag: member="lbp.h::vl_lbp_get_dimension" ref="a9fdc1d38de7ce1494cdd911bfd8957a7" args="(VlLbp *self)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="host_8h.html#a0ee26101458c663510d620e3ee7e2555">vl_size</a> vl_lbp_get_dimension </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structVlLbp.html">VlLbp</a> *&#160;</td>
          <td class="paramname"><em>self</em></td><td>)</td>
          <td><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl class="return"><dt><b>Returns:</b></dt><dd>dimension of the LBP histograms. The dimension depends on the type of quantization used. </dd></dl>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="lbp_8c.html#a3e6b2fc3465c379f3acc45c9fe5b179c" title="Create a new LBP object.">vl_lbp_new()</a>. </dd></dl>

</div>
</div>
<a class="anchor" id="a3e6b2fc3465c379f3acc45c9fe5b179c"></a><!-- doxytag: member="lbp.h::vl_lbp_new" ref="a3e6b2fc3465c379f3acc45c9fe5b179c" args="(VlLbpMappingType type, vl_bool transposed)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structVlLbp.html">VlLbp</a>* vl_lbp_new </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="lbp_8h.html#add3c75c3439f492a9c4b445d80af3d48">VlLbpMappingType</a>&#160;</td>
          <td class="paramname"><em>type</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="host_8h.html#ad32e7f8ec7333ff33998cf671a3b1412">vl_bool</a>&#160;</td>
          <td class="paramname"><em>transposed</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">type</td><td>type of LBP features. </td></tr>
    <tr><td class="paramname">transposed</td><td>if <code>true</code>, then transpose each LBP pattern. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>new <a class="el" href="structVlLbp.html" title="Local Binary Pattern extractor.">VlLbp</a> object instance. </dd></dl>

</div>
</div>
<a class="anchor" id="a605c416d7ab3906609cbb62404a20253"></a><!-- doxytag: member="lbp.h::vl_lbp_process" ref="a605c416d7ab3906609cbb62404a20253" args="(VlLbp *self, float *features, float *image, vl_size width, vl_size height, vl_size cellSize)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void vl_lbp_process </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structVlLbp.html">VlLbp</a> *&#160;</td>
          <td class="paramname"><em>self</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float *&#160;</td>
          <td class="paramname"><em>features</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float *&#160;</td>
          <td class="paramname"><em>image</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="host_8h.html#a0ee26101458c663510d620e3ee7e2555">vl_size</a>&#160;</td>
          <td class="paramname"><em>width</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="host_8h.html#a0ee26101458c663510d620e3ee7e2555">vl_size</a>&#160;</td>
          <td class="paramname"><em>height</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="host_8h.html#a0ee26101458c663510d620e3ee7e2555">vl_size</a>&#160;</td>
          <td class="paramname"><em>cellSize</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>LBP object. </td></tr>
    <tr><td class="paramname">features</td><td>buffer to write the features to. </td></tr>
    <tr><td class="paramname">image</td><td>image. </td></tr>
    <tr><td class="paramname">width</td><td>image width. </td></tr>
    <tr><td class="paramname">height</td><td>image height. </td></tr>
    <tr><td class="paramname">cellSize</td><td>size of the LBP cells.</td></tr>
  </table>
  </dd>
</dl>
<p><em>features</em> is a <code>numColumns</code> x <code>numRows</code> x <code>dimension</code> where <code>dimension</code> is the dimension of a LBP feature obtained from <a class="el" href="lbp_8h.html#a9fdc1d38de7ce1494cdd911bfd8957a7" title="Get the dimension of the LBP histograms.">vl_lbp_get_dimension</a>, <code>numColumns</code> is equal to <code>floor</code>(width / cellSize), and similarly for <code>numRows</code>. </p>

</div>
</div>
</div>
     <!-- Doc Here -->
    </div>
   
   </div>
   <div class="clear">&nbsp;</div>
  </div> <!-- pagebody -->
  <div id="footer">
   &copy; 2007-12 Andrea Vedaldi and Brian Fulkerson
  </div> <!-- footer -->

  <!-- Google Analytics Begins -->
  <script xml:space="preserve" type="text/javascript">
   //<![CDATA[
    var localre = /vlfeat.org/;
    if(document.location.host.search(localre) != -1)
    {
   var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
   document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
   }
   //]]>
  </script>
  <script xml:space="preserve" type="text/javascript">
    //<![CDATA[
    var localre = /vlfeat.org/;
    if(document.location.host.search(localre) != -1)
    {

   try {
   var pageTracker = _gat._getTracker("UA-4936091-2");
   pageTracker._trackPageview();
   } catch(err) {}

   }
   //]]>
  </script>
  <!-- Google Analytics Ends -->
 </body>
</html>

 
